package com.wugui.datax.job.mapper;

import com.wugui.datax.job.entity.HiveDemo;
import com.wugui.datax.job.mapper.base.HiveMapper;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Component;

import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

/**
 * @author luofei
 * @date 2021/6/25 13:44
 */
@Component
public class HiveDemoMapper extends HiveMapper {

    public List<HiveDemo> query() throws  Exception{
        List<HiveDemo> hiveDemoList = new ArrayList();
        ResultSet rs  =  hiveTemplate().executeQuery("select * from hive_table");
        while(rs.next()){
            HiveDemo hiveDemo = new  HiveDemo();
            hiveDemo.setId(rs.getInt("id"));
            hiveDemo.setName(rs.getString("name"));
            hiveDemoList.add(hiveDemo);
        }
        rs.close();
        return hiveDemoList;
    }
}
